//
//  changeName.m
//  BeautyPicture
//
//  Created by 沈振邦 on 15/10/16.
//  Copyright (c) 2015年 szb. All rights reserved.
//

#import "changeName.h"

#define BgColor BPColor(239, 239, 239)

@interface changeName ()

@property (nonatomic ,weak)UITextField *nameFiled;

@end

@implementation changeName

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = BgColor;
    
    UIView *bgview = [[UIView alloc] initWithFrame:CGRectMake(0, BPScreenNavY + 20.0, BPScreenW , 40)];
    [self.view addSubview:bgview];
    bgview.backgroundColor = [UIColor whiteColor];
    
    UITextField *nameFiled = [[UITextField alloc] initWithFrame:CGRectMake(10, 0, bgview.width - 20, 40.0)];
    nameFiled.text = self.beforeName;
    nameFiled.textAlignment = NSTextAlignmentLeft;
    nameFiled.clearButtonMode = YES;
    nameFiled.backgroundColor = [UIColor whiteColor];
    [bgview addSubview:nameFiled];
    _nameFiled = nameFiled;
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"保存" style:UIBarButtonItemStyleDone target:self action:@selector(saveInfo)];
    // Do any additional setup after loading the view.
}

-(void)saveInfo
{
    if ([_nameFiled.text length] <= 10) {
        _block(_nameFiled.text);
        [self.navigationController popViewControllerAnimated:YES];
    }else{
        UIAlertView *imageCountWarningalert = [[UIAlertView alloc] initWithTitle:@"gank"
                                                                         message:@"最多10字"
                                                                        delegate:self
                                                               cancelButtonTitle:nil
                                                               otherButtonTitles:@"确定", nil];
        [imageCountWarningalert show];
    }
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
